diff options
author | Ptyl Dragon <ptyl@cloudon.com> | 2013-10-19 12:51:02 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2013-10-19 10:05:27 +0000 |
commit | 1034a2eb97a291846ff0d9b67677946ecab7df87 (patch) | |
tree | 64af851cee90f9f1068fb95593f4f5172a03bffe /ios | |
parent | 07d7be1ac8be39c9a4333c7166600180b8dd2475 (diff) |
added save to ios app and removed keyboard on open
Change-Id: Ibfa9373cc82d7e2022190e158f94eb323a57f241
Reviewed-on: https://gerrit.libreoffice.org/6351
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'ios')
6 files changed, 53 insertions, 8 deletions
diff --git a/ios/shared/ios_sharedlo/cxx/mlo_uno.h b/ios/shared/ios_sharedlo/cxx/mlo_uno.h index d9ec63bcc3ff..df531905c312 100644 --- a/ios/shared/ios_sharedlo/cxx/mlo_uno.h +++ b/ios/shared/ios_sharedlo/cxx/mlo_uno.h @@ -23,6 +23,7 @@ extern "C" { void mlo_get_selection(NSMutableString * mutableString); void mlo_fetch_view_data(NSMutableString * mutableString); void mlo_select_all(void); + void mlo_save(void); #ifdef __cplusplus } diff --git a/ios/shared/ios_sharedlo/cxx/mlo_uno.mm b/ios/shared/ios_sharedlo/cxx/mlo_uno.mm index ff92821f0fff..20c079bb8c83 100644 --- a/ios/shared/ios_sharedlo/cxx/mlo_uno.mm +++ b/ios/shared/ios_sharedlo/cxx/mlo_uno.mm @@ -26,6 +26,7 @@ #include "com/sun/star/frame/XDispatchHelper.hpp" #include <com/sun/star/frame/DispatchHelper.hpp> #include "com/sun/star/frame/XComponentLoader.hpp" +#include "com/sun/star/frame/XStorable.hpp" #include "com/sun/star/awt/XScrollBar.hpp" #include <com/sun/star/container/XContentEnumerationAccess.hpp> #include <com/sun/star/frame/Desktop.hpp> @@ -83,6 +84,7 @@ Reference<XSearchable> openedXSearchable; Reference<XSelectionSupplier> openedXSelectionSupplier; Reference<XFrame> openedXFrame; Reference<XDispatchProvider> openedXDispatchProvider; +Reference<XStorable> openedXStorable; Reference<XIndexAccess> currentFindAll; rtl::OUString lastSearch; @@ -229,6 +231,15 @@ Reference<XDispatchHelper> getXDispatchHelper(){ return helper; } +Reference<XStorable> getXStorable(){ + if(!openedXStorable.get()){ + Reference<XStorable> stroable(getXModel(),UNO_QUERY); + openedXStorable.set(stroable); + LOG_EVAL(openedXStorable, @"XDispatchProvider"); + } + return openedXStorable; +} + NSString * createFileUri(NSString * file){ if(file==nil){ NSString * app_root_escaped = [[[NSBundle mainBundle] bundlePath] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; @@ -477,4 +488,18 @@ mlo_select_all(void){ OUString("_self"), 0, Sequence<PropertyValue >()); +} + +extern "C" +void +mlo_save(void){ + if(mlo_is_document_open()){ + Reference<XStorable> storable =getXStorable(); + if(storable->isReadonly()){ + NSLog(@"Cannot save changes. File is read only"); + }else{ + storable->store(); + NSLog(@"saved changes"); + } + } }
\ No newline at end of file diff --git a/ios/shared/ios_sharedlo/objective_c/gestures/MLOKeyboardManager.h b/ios/shared/ios_sharedlo/objective_c/gestures/MLOKeyboardManager.h index c30fda01b142..6649ce00045b 100644 --- a/ios/shared/ios_sharedlo/objective_c/gestures/MLOKeyboardManager.h +++ b/ios/shared/ios_sharedlo/objective_c/gestures/MLOKeyboardManager.h @@ -15,4 +15,6 @@ -(void)addToMainViewController; -(void)show; -(void)hide; +-(void)showLibreOffice; +-(void)hideLibreOffice; @end diff --git a/ios/shared/ios_sharedlo/objective_c/gestures/MLOKeyboardManager.m b/ios/shared/ios_sharedlo/objective_c/gestures/MLOKeyboardManager.m index f7d483fe1b09..fde1d8263c37 100644 --- a/ios/shared/ios_sharedlo/objective_c/gestures/MLOKeyboardManager.m +++ b/ios/shared/ios_sharedlo/objective_c/gestures/MLOKeyboardManager.m @@ -15,6 +15,7 @@ @interface MLOKeyboardManager () @property MLOMainViewController * mainViewController; @property UITextView * textView; +@property BOOL allowLoToinvokdeKeyboard; @property BOOL isShown; @end @@ -40,6 +41,13 @@ -(void)addToMainViewController{ [self.mainViewController.canvas addSubview:self.textView]; } +-(void)hideLibreOffice{ + self.allowLoToinvokdeKeyboard =NO; + [self hide]; +} +-(void)showLibreOffice{ + self.allowLoToinvokdeKeyboard =NO; +} -(void)initTextView{ self.textView = [[UITextView alloc] initWithFrame:CGRECT_ONE]; self.textView.alpha = 0.0f; @@ -77,6 +85,13 @@ return NO; } +-(void)loInvokeKeyboard{ + if(self.allowLoToinvokdeKeyboard){ + [self show]; + }else{ + self.allowLoToinvokdeKeyboard = YES; + } +} -(BOOL)canBecomeFirstResponder{ return YES; @@ -103,7 +118,7 @@ void touch_ui_show_keyboard() { dispatch_async(dispatch_get_main_queue(), ^{ - [[MLOManager getInstance].mainViewController.keyboard show]; + [[MLOManager getInstance].mainViewController.keyboard loInvokeKeyboard]; }); } @@ -118,7 +133,7 @@ bool touch_ui_keyboard_visible() { // Should return info whether the soft keyboard is currently displayed, // or a hardware keyboard is attached/paired. - return false; + return [MLOManager getInstance].mainViewController.keyboard.isShown; } @end diff --git a/ios/shared/ios_sharedlo/objective_c/view_controllers/role/MLOAppRoleLoApp.m b/ios/shared/ios_sharedlo/objective_c/view_controllers/role/MLOAppRoleLoApp.m index 1fad45bcec94..fc3fb4ce004a 100644 --- a/ios/shared/ios_sharedlo/objective_c/view_controllers/role/MLOAppRoleLoApp.m +++ b/ios/shared/ios_sharedlo/objective_c/view_controllers/role/MLOAppRoleLoApp.m @@ -88,6 +88,7 @@ static const NSTimeInterval ROTATE_FLASH_DURATION=0.5f; -(void)showLibreOffice{ [self.mainViewController.toolbar showLibreOffice]; + [self.mainViewController.keyboard showLibreOffice]; } -(void)hideLibreOffice{ @@ -98,7 +99,7 @@ static const NSTimeInterval ROTATE_FLASH_DURATION=0.5f; [main.gestureEngine hideLibreOffice]; [main.scroller hideLibreOffice]; [main.selection reset]; - [main.keyboard hide]; + [main.keyboard hideLibreOffice]; } -(void)initWindow:(UIWindow *) window{ diff --git a/ios/shared/ios_sharedlo/objective_c/view_controllers/toolbar/MLOToolbarViewController.m b/ios/shared/ios_sharedlo/objective_c/view_controllers/toolbar/MLOToolbarViewController.m index ef241cea7344..83a689cf7ef3 100644 --- a/ios/shared/ios_sharedlo/objective_c/view_controllers/toolbar/MLOToolbarViewController.m +++ b/ios/shared/ios_sharedlo/objective_c/view_controllers/toolbar/MLOToolbarViewController.m @@ -15,6 +15,7 @@ #import "MLOResourceImage.h" #import "MLOTopbarViewController.h" #import "MLOKeyboardManager.h" +#import "mlo_uno.h" @interface MLOToolbarViewController () @property NSArray * buttons; @@ -32,9 +33,9 @@ self.mainViewController = mainViewController; self.buttons=@[[self createExpandButton], [self createFindButton], - [self createEditButton]//, - //[self createPrintButton], - //[self createSaveButton] + [self createEditButton], + [self createSaveButton] + //[self createPrintButton] ]; self.tappable = NO; @@ -129,8 +130,8 @@ -(MLOToolbarButton *)createSaveButton{ return [MLOToolbarButton buttonWithImage: [MLOResourceImage save] - onTap: MLO_TOOLBAR_BUTTON_STUB_CALLBACK - tapRelease: RETAP_OR_OTHER_TAPPED]; + onTap: ^{ mlo_save(); } + tapRelease: AUTOMATIC]; } @end |