[Libreoffice-commits] core.git: ios/shared
Ptyl Dragon
ptyl at cloudon.com
Sat Oct 19 03:05:46 PDT 2013
ios/shared/ios_sharedlo/cxx/mlo_uno.h | 1
ios/shared/ios_sharedlo/cxx/mlo_uno.mm | 25 ++++++++++
ios/shared/ios_sharedlo/objective_c/gestures/MLOKeyboardManager.h | 2
ios/shared/ios_sharedlo/objective_c/gestures/MLOKeyboardManager.m | 19 ++++++-
ios/shared/ios_sharedlo/objective_c/view_controllers/role/MLOAppRoleLoApp.m | 3 -
ios/shared/ios_sharedlo/objective_c/view_controllers/toolbar/MLOToolbarViewController.m | 11 ++--
6 files changed, 53 insertions(+), 8 deletions(-)
New commits:
commit 1034a2eb97a291846ff0d9b67677946ecab7df87
Author: Ptyl Dragon <ptyl at cloudon.com>
Date: Sat Oct 19 12:51:02 2013 +0200
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 at collabora.com>
Tested-by: Tor Lillqvist <tml at collabora.com>
diff --git a/ios/shared/ios_sharedlo/cxx/mlo_uno.h b/ios/shared/ios_sharedlo/cxx/mlo_uno.h
index d9ec63b..df53190 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 ff92821..20c079b 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 c30fda0..6649ce0 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 f7d483f..fde1d82 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;
+ at 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 1fad45b..fc3fb4c 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 ef241ce..83a689c 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
More information about the Libreoffice-commits
mailing list