summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPtyl Dragon <ptyl@cloudon.com>2013-10-23 11:55:16 +0200
committerPtyl Dragon <ptyl@cloudon.com>2013-10-24 11:30:55 +0200
commit9fd0abe9abfe37cb1591e1db794e0c921d95b172 (patch)
treedf5f52ffb832a7336bd5582bb13a312845476823
parent2d09baa7802e5d5bf30bd4baafe690f06a1275ec (diff)
added links to the image in tiled rendering
Change-Id: Ic9d972fd67123e3ab04f023806f7f96c89a883a7
-rw-r--r--sw/qa/tiledrendering/tiledrendering.cxx125
-rw-r--r--sw/qa/tiledrendering/tiledrendering.ui2
2 files changed, 85 insertions, 42 deletions
diff --git a/sw/qa/tiledrendering/tiledrendering.cxx b/sw/qa/tiledrendering/tiledrendering.cxx
index bfd20c327706..6af94eca6873 100644
--- a/sw/qa/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/tiledrendering/tiledrendering.cxx
@@ -21,37 +21,68 @@
#include <vcl/vclmain.hxx>
#include <vcl/field.hxx>
#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::sfx2;
-class UIPreviewApp : public Application
+class TiledRenderingApp : public Application
{
+private:
+ uno::Reference<uno::XComponentContext> xContext;
+ uno::Reference<lang::XMultiComponentFactory> xFactory;
+ uno::Reference<lang::XMultiServiceFactory> xSFactory;
+ uno::Reference<uno::XInterface> xDesktop;
+ uno::Reference<frame::XComponentLoader> xLoader;
+ uno::Reference<lang::XComponent> xComponent;
public:
virtual void Init();
virtual int Main();
+ void Open(OUString & aFileUrl);
};
-using namespace com::sun::star;
class TiledRenderingDialog: public ModalDialog{
+private:
+ TiledRenderingApp * app;
public:
- TiledRenderingDialog() : ModalDialog(DIALOG_NO_PARENT, "TiledRendering", "qa/sw/ui/tiledrendering.ui")
+ TiledRenderingDialog(TiledRenderingApp * app) :
+ ModalDialog(DIALOG_NO_PARENT, "TiledRendering", "qa/sw/ui/tiledrendering.ui"),
+ app(app)
{
PushButton * renderButton;
get(renderButton,"buttonRenderTile");
renderButton->SetClickHdl( LINK( this, TiledRenderingDialog, RenderHdl));
+
+ PushButton * chooseDocumentButton;
+ get(chooseDocumentButton,"buttonChooseDocument");
+ chooseDocumentButton->SetClickHdl( LINK( this, TiledRenderingDialog, ChooseDocumentHdl));
+
SetStyle(GetStyle()|WB_CLOSEABLE);
}
+
virtual ~TiledRenderingDialog()
{
}
DECL_LINK ( RenderHdl, Button * );
+ DECL_LINK ( ChooseDocumentHdl, Button * );
- sal_Int32 extractInt(const char * name)
+ sal_Int32 ExtractInt(const char * name)
{
NumericField * pField;
get(pField,name);
OUString aString(pField->GetText());
- std::cerr << "param " << name << " returned " << aString <<"/n";
return aString.toInt32();
}
@@ -59,67 +90,79 @@ public:
IMPL_LINK ( TiledRenderingDialog, RenderHdl, Button *, EMPTYARG )
{
- extractInt("spinContextWidth");
- extractInt("spinContextHeight");
- extractInt("spinTilePosX");
- extractInt("spinTilePosY");
- extractInt("spinTileWidth");
- extractInt("spinTileHeight");
+ ExtractInt("spinContextWidth");
+ ExtractInt("spinContextHeight");
+ ExtractInt("spinTilePosX");
+ ExtractInt("spinTilePosY");
+ ExtractInt("spinTileWidth");
+ ExtractInt("spinTileHeight");
+ FixedImage * pImage;
+ get(pImage,"imageTile");
+ return 1;
+}
+
+IMPL_LINK ( TiledRenderingDialog, ChooseDocumentHdl, Button *, EMPTYARG )
+{
+ FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
+ uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
+ if( aDlgHelper.Execute() == ERRCODE_NONE )
+ {
+ OUString aFileUrl =xFP->getFiles().getConstArray()[0];
+ app->Open(aFileUrl);
+ }
return 1;
}
-void UIPreviewApp::Init()
+void TiledRenderingApp::Open(OUString & aFileUrl){
+ static const OUString TARGET("_default");
+ static const Sequence<beans::PropertyValue> PROPS (0);
+ if(xComponent.get())
+ {
+ xComponent->dispose();
+ xComponent.clear();
+ }
+ xComponent.set(xLoader->loadComponentFromURL(aFileUrl,TARGET,0,PROPS));
+}
+
+void TiledRenderingApp::Init()
{
- uno::Reference<uno::XComponentContext> xContext =
- cppu::defaultBootstrap_InitialComponentContext();
- uno::Reference<lang::XMultiComponentFactory> xFactory =
- xContext->getServiceManager();
- uno::Reference<lang::XMultiServiceFactory> xSFactory =
- uno::Reference<lang::XMultiServiceFactory> (xFactory, uno::UNO_QUERY_THROW);
+ xContext.set(cppu::defaultBootstrap_InitialComponentContext());
+ xFactory.set(xContext->getServiceManager());
+ xSFactory.set(uno::Reference<lang::XMultiServiceFactory> (xFactory, uno::UNO_QUERY_THROW));
comphelper::setProcessServiceFactory(xSFactory);
// Create UCB (for backwards compatibility, in case some code still uses
// plain createInstance w/o args directly to obtain an instance):
- ::ucb::UniversalContentBroker::create(
- comphelper::getProcessComponentContext() );
+ ::ucb::UniversalContentBroker::create(comphelper::getProcessComponentContext() );
+
+ xDesktop.set(xFactory->createInstanceWithContext(OUString("com.sun.star.frame.Desktop"), xContext));
+ xLoader.set(frame::Desktop::create(xContext));
}
-int UIPreviewApp::Main()
+int TiledRenderingApp::Main()
{
- //std::vector<OUString> uifiles;
- //for (sal_uInt16 i = 0; i < GetCommandLineParamCount(); ++i)
- //{
- // OUString aFileUrl;
- // osl::File::getFileURLFromSystemPath(GetCommandLineParam(i), aFileUrl);
- // uifiles.push_back(aFileUrl);
- //}
- //if (uifiles.empty())
- //{
- // fprintf(stderr, "Usage: ui-previewer file.ui\n");
- // return EXIT_FAILURE;
- //}
-
- // turn on tooltips
+ if(GetCommandLineParamCount()>0)
+ {
+ OUString aFileUrl;
+ osl::File::getFileURLFromSystemPath(GetCommandLineParam(0), aFileUrl);
+ Open(aFileUrl);
+ }
Help::EnableQuickHelp();
-
try
{
-
- TiledRenderingDialog pDialog;
-
+ TiledRenderingDialog pDialog(this);
pDialog.Execute();
}
catch (const uno::Exception &e)
{
fprintf(stderr, "fatal error: %s\n", OUStringToOString(e.Message, osl_getThreadTextEncoding()).getStr());
}
-
return EXIT_SUCCESS;
}
void vclmain::createApplication()
{
- static UIPreviewApp aApp;
+ static TiledRenderingApp aApp;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/tiledrendering/tiledrendering.ui b/sw/qa/tiledrendering/tiledrendering.ui
index f27939c00d87..22222d4b46d7 100644
--- a/sw/qa/tiledrendering/tiledrendering.ui
+++ b/sw/qa/tiledrendering/tiledrendering.ui
@@ -256,7 +256,7 @@
</packing>
</child>
<child>
- <object class="GtkImage" id="image1">
+ <object class="GtkImage" id="imageTile">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>